package com.shujia.MR.output;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;


/**
 * 由于排序并不需要Reduce端进行聚合操作，所以只需要写Mapper端
 * 1500100001	施笑槐*22*女*文科六班*406
 */
public class OutMapper extends Mapper<LongWritable, Text, Student, NullWritable> {

    // 排序时，是按照写出Key进行排序，对Value值不做任何操作
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Student, NullWritable>.Context context) throws IOException, InterruptedException {
        String[] KV = value.toString().split("\t");
        String[] columns = KV[1].split("\\*");
        Student student = new Student(KV[0], columns[0], columns[1], columns[2], columns[3], columns[4]);
        context.write(student, NullWritable.get());
    }
}
